<% content_for :title, "Supervision" %>
<% content_for("page_header") do %>
<%= stylesheet_link_tag 'rooms.css' %>
<!---
<%= javascript_include_tag "prototype" %>
<%= javascript_include_tag "dragdrop" %>
-->

<% end %>

<h1>Salles <%= image_tag "icons/ajax-loader.gif", :id=>"wait_icon", :class=>"hidden" %></h1>

<div id="rooms_global">

	<div id="rooms_listing">
		<% @rooms.each do |room| %>
		
			<div id="room_statut_<%=h room.id %>" class="room_statut">
				<% if @events.include? room.id %>
					<%= image_tag "icons/warning.png", :title=>'Problème(s) en cours' %>
				<% end %>
			</div>

			<div class="room_section">
				<%= link_to_remote image_tag("icons/meeting_room.png", :id=>"room_#{room.id}"),
					{
						:url=>{:action => :get_room, :id => room.id},
						:update => "rooms_computers",
						:before => "Element.show('wait_icon')",
						:complete => "Element.hide('wait_icon')"
					},
					:href=>(url_for :action=>:show, :id => room.id)

				%>



				<div class="room_title">
					<%=h room.name %>

				</div>
			</div>

			<%= drop_receiving_element "room_#{room.id}",
										:url=>{ :controller => :computers,
												:action => :switch_room,
												:width => "room.id=#{room.id}"},
										:before => "Element.show('wait_icon')",
										:success => "Element.hide('wait_icon'); Element.hide('computer_section_'+element.id.split('_').last()); showMessage('Ordinateur déplacé dans la salle "+room.name+"', 'success'); checkExistEvents(#{room.id});",
										:error => "Element.hide('wait_icon')",
										:complete => "Element.hide('wait_icon')"
			%>
		<% end %>

		<div id="room_statut_<%=h @riddance[:id] %>" class="room_statut">
			<% if @riddance_events.include? @riddance[:id] %>
				<%= image_tag "icons/warning.png", :title=>'Problème(s) en cours' %>
			<% end %>
		</div>

		<div class="room_section">
			<%= link_to_remote image_tag("icons/meeting_room.png", :id=>"room_#{@riddance[:id]}"),
				{
					:url=>{:action => :get_room, :id => @riddance[:id]},
					:update => "rooms_computers",
					:before => "Element.show('wait_icon')",
					:complete => "Element.hide('wait_icon')"
				},
				:href=>(url_for :action=>:show, :id => @riddance[:id])

			%>



			<div class="room_title">
				<%=h @riddance[:name] %>

			</div>
		</div>

		<%= drop_receiving_element "room_#{@riddance[:id]}",
									:url=>{ :controller => :computers,
											:action => :switch_room,
											:width => "room.id=#{@riddance[:id]}"},
									:before => "Element.show('wait_icon')",
									:success => "Element.hide('wait_icon'); Element.hide('computer_section_'+element.id.split('_').last()); showMessage('Ordinateur déplacé dans la salle "+@riddance[:name]+"', 'success'); checkExistEvents(#{@riddance[:id]});",
									:error => "Element.hide('wait_icon')",
									:complete => "Element.hide('wait_icon')"
		%>

	</div>

	<div id="rooms_computers">
		<%= image_tag('icons/arrow_left.png' ,:title => 'Sélectionnez une salle') %> <span class="size_medium">Sélectionnez une salle</span><br />

		<br />
		<h2>Statistiques immédiates</h2>
		<br />

		<%= image_tag('icons/warning.png' ,:title => 'Nombre d\'incidents') %> Nombre d'incidents : <%= @events_count %><br />

		<%= image_tag('icons/computer.png' ,:title => 'Nombre d\'ordinateurs') %> Nombre d'ordinateurs : <%= @computers_count %> 
		 
		 <%= link_to 'Voir la liste',
			computers_path,
			:class => 'button bg_orange list' %>

		<br />

	</div>

</div>

<div id="rooms_administration">
	<% if current_user %>
		<%= link_to 'Ajouter une salle', new_room_path, :class => 'button add' %><br /><br />
		
		<%= link_to_remote 'MAJ des AV',
						{
							:url=>{:controller => :computers, :action => :update_av, :id => "all"},
							:loading=>visual_effect(:appear, 'loader_av'),
							:loaded=>visual_effect(:blind_up, 'loader_av', :duration => 2),
						},
						:href=>(url_for :controller => :computers, :action => :update_av, :id => "all"),
						:class => 'button bg_green update width_135'

					%> 
		<span id="av_update_all"></span><br /><br />
		<%= image_tag('icons/ajax-loader.gif' ,:style =>'display:none',:id=> 'loader_av') %><br />
	<% end %>
</div>

<div class="clear_both"></div>